//
//  Coordinate.m
//  citycar
//
//  Created by Tang JiaQi on 4/2/11.
//  Copyright 2011 HOME. All rights reserved.
//

#import "Coordinate.h"

#define WIDTH_IN_REAL_WORLD		8.f
#define HEIGHT_IN_REAL_WORLD	12.f

@implementation Coordinate

+(CGPoint) screenToRealWorld: (CGPoint) pos
{
	CGSize winSize = [[CCDirector sharedDirector] winSize];
	return ccp((pos.x - winSize.width / 2.f) / (winSize.width / 2.f) * (WIDTH_IN_REAL_WORLD / 2.f),
			   (pos.y / winSize.height * HEIGHT_IN_REAL_WORLD));
}

+(CGPoint) realWorldToScreen: (CGPoint) pos
{
	CGSize winSize = [[CCDirector sharedDirector] winSize];
	return ccp(pos.x / (WIDTH_IN_REAL_WORLD / 2.f) * (winSize.width / 2.f) + winSize.width / 2.f,
			   pos.y / HEIGHT_IN_REAL_WORLD * winSize.height);
}

@end
